import React from 'react'
// Route组件的作用:帮助我们快速定义前端路由规则
import {
  Route,
  Link,
  Switch,
  Redirect,
  NavLink,
  withRouter,
} from 'react-router-dom'
import Home from './pages/Home'
import Login from './pages/Login'

const WithApp = withRouter(App)
function App(props) {
  console.log(props)
  return (
    <div>
      <button
        onClick={() => {
          props.history.push('/home')
        }}
      >
        点击切换到home页面
      </button>
      <hr />
      <NavLink to="/home">首页</NavLink>
      <NavLink to="/login">登录</NavLink>
      <hr />
      <Switch>
        <Route path="/home/:id?" component={Home}></Route>
        <Route path="/login" component={Login}></Route>
      </Switch>
      <hr />
    </div>
  )
}

export default WithApp
